<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@page import="com.cap.bts.framework.usermgnt.constant.EmployeeStatus"%>    
    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>MARS接口参数配置</title>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="core" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="validator" uri="http://www.springmodules.org/tags/commons-validator" %>
<core:set var ="webcontext" scope="request" value="${pageContext.request.contextPath}"/>
<core:set var ="imagepath" scope="request" value="${webcontext}/images"/>
<core:set var ="csspath" scope="request" value="${webcontext}/css"/>
<core:set var ="jspath" scope="request" value="${webcontext}/javascript"/>
<core:set var ="jsppath" scope="request" value="${webcontext}/jsp"/>
<core:set var ="htmlpath" scope="request" value="${webcontext}/html"/>
<core:set var ="bootstrapPath" scope="request" value="${webcontext}/bootstrap"/>
<core:set var ="layerPath" scope="request" value="${webcontext}/layer"/>
<!-- TODO the gdms url should replace by the token -->
<core:set var ="gdmsurl" scope="request" value="@token-gdms.server.servlet.context.url.integration@"/>
<script type="text/javascript">
	var contextPath = "${webcontext}";
</script>
<%@page import="com.cap.bts.framework.common.util.Pager"%>
<%@page import="com.cap.bts.framework.common.constant.CommonConstants"%>
<%@page import="com.cap.bts.framework.common.util.CodeTextUtils"%>
<%@page import="com.cap.bts.framework.common.util.CookieUtils"%>
<%@page import="com.cap.bts.framework.auth.constant.AuthConstant"%>

<script type="text/javascript" src="${jspath }/jquery/jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="${jspath }/../layer/layer.js"></script>
<link rel="stylesheet" type="text/css"	href="${bootstrapPath}/css/bootstrap.css" />
<style type="text/css">
* {
	margin: 0px;
	padding: 0px;
	font-size: 14px;
	font-family: sans-serif;
}
th{white-space:nowrap;color: #FFF; background:#00af4e;}
th,td{border: 1px solid #ddd; }
.encrypt{max-width:300px;word-wrap: break-word; word-break: normal; }
.normalXml{max-width:250px;word-wrap: break-word; word-break: normal; }
.search{text-align:center;padding:15px;}
.michelin-btn{background-color:#00af4e; color:#FFF; border:none;padding: 5px 15px;margin-left:20px;}
input{width:350px;font-weight:bold;text-left; height:30px;}

.form-group{margin:10px;}
.form-group label{width:150px; text-align:right;}
</style>

<script type="text/javascript">
$(function(){
	
});

	function save() {
		var layerIndex = layer.load(1, {
		    shade: [0.4,'#000'] 
		});

		$.ajax({
			type : 'POST',
			dataType:'json',
			url : '${webcontext}/marsConfig/save',
			async : true,
			data : $("#configForm").serialize(),
			dataType : 'json',
			success : function(data) {
				layer.close(layerIndex);
				if(data.success){
					layer.alert("保存成功！", {icon : 1});
				};
			},
			error: function(){
				layer.close(layerIndex);
				layer.alert("操作失败！", {icon : 2});
			}
		});
	}
</script> 
</head>
<body>

<form id="configForm">
 <div style="width:900px;">
 	<div class="form-group">
	 	<label>Token</label>
	 	<input type="text" name="token" value="${requestScope.config.token }">
 	</div>
 	<div class="form-group">
	 	<label>MARS domain</label>
	 	<input type="text" name="serverDomain" value="${requestScope.config.serverDomain }">
 	</div>
 	<div class="form-group">
	 	<label>MARS port</label>
	 	<input type="text" name="serverPort" value="${requestScope.config.serverPort }">
 	</div>
 	<div class="form-group">
	 	<label>PROTOCOL</label>
	 	<input type="text" name="protocol" value="${requestScope.config.protocol }">
 	</div>
 	<div class="form-group">
	 	<label>MARS_SERVICE_NAME</label>
	 	<input type="text" name="marsServiceName" value="${requestScope.config.marsServiceName }">
 	</div>
 	<div class="form-group">
	 	<label>USER_NAME</label>
	 	<input type="text" name="userName" value="${requestScope.config.userName }">
 	</div>
 	<div class="form-group">
	 	<label>Password</label>
	 	<input type="text" name="pwd" value="${requestScope.config.pwd }">
 	</div>
 	<div class="form-group">
	 	<label>AUTH_MODE</label>
	 	<input type="text" name="authMode" value="${requestScope.config.authMode }">
	 	HTTP_BASIC  or AAD
 	</div>
 	<div class="form-group">
	 	<label>AAD Config(AUTH_MODE 为AAD时配置)<BR/><BR/><BR/><BR/><BR/><BR/></label>
	 	<textarea name="descp" style="width:500px; height:150px;">${requestScope.config.descp }</textarea>
	 	<br/>AAD Config example:
	 	<pre>
	 	{
		  "authority": "https://login.chinacloudapi.cn/b7baf999-1be3-4c6e-a6c5-e84badfac299/oauth2/authorize",
		  "clientId": "2f19aa37-1076-42df-a2a7-97f9c02ef769",
		  "clientSecret": "MNxVcrsEOPowPS/ugqNBS9FhFCHm65T8gkIyXDSU400=",
		  "userName": "chen.ma@testfj.partner.onmschina.cn",
		  "password": "******",
		  "resource": "http://marsns.chinacloudapp.cn:8080/chinactpdemoaad/webclient/"
		}
	 	</pre>
 	</div>
 	<div style="text-align:center; margin-top:30px;">
	 	<button class="michelin-btn" onclick="save()" type="button">保 存</button>
 	</div>
 </div>
</form>

</body>
</html>